#!/usr/bin/env bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH




# 2.生成自签名证书
function generate_self_cert(){
	echo -e "${Info} ${full_line} 生成自签名证书 start...${full_line}" && echo
	
	
	
	#公网IP
	CommonName=`wget -qO- -t1 -T2 ipinfo.io/ip`
	echo -e "公网IP：${CommonName}"
	
	while true
	do
		if [[ -z ${CommonName} ]]; then
			echo "${Green_font_prefix}${Tip}：获取服务器公网IP失败，请手动输入IP：{Font_color_suffix}" CommonName
		else
			break
		fi
	done
	
	echo -e "你的公网IP是：${CommonName}"
	
	
	while true
	do
		
		read -e -p "输入域名：" domain
		
		echo -e "你输入的域名：${domain}"
		read -e -p "是否确认(Y/y)：" un
		if [[ ${un} == [Yy] ]]; then
			break
		fi
	done
	

	echo -e "进入证书目录：${webdav_go_cert_folder}"
	cd ${webdav_go_cert_folder}
	
	# (generate_rootCA.sh)
	set_openssl_cnf
	generate_rootCA
	
	echo -e "${Info} ${full_line} 生成自签名证书 END...${full_line}" && echo
}


#11.下载根证书
function download_root_cert(){
	cd ${webdav_go_cert_folder}
	yum -y install lrzsz
	sz ca.crt
}




